<?php
/**
 * @since 26.07.12 10:55
 * @author Arsen Abdusalamov
 */
class SitemapCommand extends CConsoleCommand
{
	/**
	 * @since 26.07.12 10:56
	 * @author Arsen Abdusalamov
	 * @param type $type
	 * @param type $limit 
	 */
    public function actionIndex( $csvFileName ) {
		assert( !empty( $csvFileName ) );
		assert( is_file( $csvFileName ) );

		if (($handle = fopen($csvFileName, "r")) !== FALSE) {
			$line = fgets( $handle );
			while (($line = fgets( $handle )) !== FALSE) {
				$data = explode(';', $line );
				echo $data[0].' ';
				$content = new Content();
				$content->title = $data[2];
				//$content->author = 'Arsen Abdusalamov';
				$content->slug = $data[0];
				//die( $data[1] );
				$content->content = gzuncompress( base64_decode( $data[3] ) );
				echo ( $content->save() ? $content->id : 'no' ) . PHP_EOL;
			}
			fclose($handle);
		}
	}
	 
	/**
	 *  
	 * @since 26.07.12 10:56
	 * @author Arsen Abdusalamov
	 */
    public function actionInit() {
		
	}
}